<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');

/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Core-File to create Outputpage
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
/* @var $menu	Menustucture as follow
 * 				1. Element Page link (URL) Topmenu
 * 				2. Element Text for Topmenu
 */
$menu = array('info' => array('info',
  _('Info'),
 ),
 'page' => array(
  'page',
  _('Pages')
 ),
 'mail' => array(
  'mail',
  _('Mail')
 ),
 'article' => array(
  'article',
  _('Article')
 ),
 'user' => array(
  'user',
  _('User')
 ),
 'config' => array(
  'config',
  _('Configuration')
 ),
 'system' => array(
  'system',
  _('System')
 )
);

// Set Layout-Variables for Header-Area
$page->assign('index_tpl_titel', _('Adminpanel | TobbiVM-Shop'));
$page->assign('index_tpl_Welcome', _('Welcome') . ' ' . $_SESSION['username']);
$page->assign('index_tpl_LogoutLink', '<a href="index.php?logout" class="logout">' . _('Logout'));

if (isset($_GET['logout']))
	resetUser();

// Set Topmenu
include_once 'module/menu/topmenu.php';
if (!isset($_GET['page']) or !isset($menu[$_GET['page']]))
{
	$_GET['page'] = 'info';
}
else
{
	$_GET['page'] = $validate->cleanslash($_GET['page']);
}
topmenu($_GET['page'], $page, $menu);

include_once 'module/function/help.func.php';
// Set Leftmenu
include_once 'module/menu/leftmenu.php';
if (!isset($_GET['sub']))
{
	$_GET['sub'] = '-';
}
else
{
	$_GET['sub'] = $validate->cleanslash($_GET['sub']);
}
leftmenu($_GET['page'], $_GET['sub'], $page);

// Get content
$pagefile = 'module/page/' . $_GET['page'] . '/' . $_GET['sub'] . '.page.php';
if (is_file($pagefile))
{
	include_once $pagefile;
}

contentPage($page, $_GET['page'], $_GET['sub'], $validate);

if (message::ifErrorMessage())
{
	$page->assign('errorText', message::getErrorText());
	$page->addtpl('errorText', '/errorbox.tpl.php');
}

if (message::ifWarningMessage())
{
	$page->assign('warningText', message::getWarningText());
	$page->addtpl('warningText', '/warningbox.tpl.php');
}

if (message::ifNoteMessage())
{
	$page->assign('noteText', message::getNoteText());
	$page->addtpl('noteText', '/notebox.tpl.php');
}
?>